<template>
  <i-frame :src="openUrl" />
</template>

<script>
import { getToken } from "@/utils/auth";
import iFrame from "@/components/iFrame/index";

export default {
  name: "jimuview",
  components: { iFrame },
  props: {
    reportID: {
      type: String,
      required: false,
      default: "",
    },
    type: {
      type: String,
      required: false,
      default: "",
    },
  },
  data() {
    return {
      // serverUrl: "http://127.0.0.1:8080",
      // serverUrl: import.meta.env.VITE_APP_BASE_API,
      // 发布路径
      // serverUrl: "http://" + location.hostname + "/report/jmreport/view/",
      // 本地测试路径
      // serverUrl: "http://tms-gateway-crjz2027-jz-tms.crsems-uat.crc.com.cn/report/jmreport/view/" ,
      openUrl: "",
    };
  },
  computed: {
    serverUrl() {
      // 查看是view   编辑是index  
      console.log(location.hostname)
      let href= ''
      if(this.type=='view'){
        href = 'view/'
      } else {
        href = 'index/'
      }
      return (location.hostname === "localhost" || location.hostname.indexOf('10.54.48.104')>-1) ? 
      "http://et-mes-ui-resolinkpoc2023-et-mes.crsems.crcloud.com/report/jmreport/" + href: 
      "http://" + location.hostname + "/report/jmreport/"+href
    }
  },
  created() {
    if (this.reportID.length !== 0) {
      this.openUrl =
        this.serverUrl + this.reportID + "?token=" + getToken();
    } else {
      // this.$route.path.substring(this.$route.path.lastIndexOf("/") + 1)
      this.openUrl = this.serverUrl + this.reportID +"?token=" +getToken();
    }
    console.log(this.openUrl);
  },
};
</script>

<style scoped></style>
